package com.kinon.tyjaccount.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.kinon.tyjaccount.R;
import com.kinon.tyjaccount.entity.WucanEntity;
import com.kinon.tyjaccount.tools.HttpTools;

import java.util.ArrayList;

/**结算界面菜单*/

public class WucanAdapter extends BaseAdapter{
	Context context;
	ArrayList<WucanEntity> wucanList;
	HttpTools httpTools=null;
	
	public WucanAdapter(Context context, ArrayList<WucanEntity> wucanList) {
		super();
		this.context = context;
		this.wucanList = wucanList;
	}
	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return wucanList.size()>30?30:wucanList.size();
	}

	@Override
	public Object getItem(int position) {
		// TODO Auto-generated method stub
		return wucanList.get(position);
	}

	@Override
	public long getItemId(int position) {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	public View getView(int position, View view, ViewGroup parent) {
		final ViewHandle handle;
		if(view==null){
			handle=new ViewHandle();
			view=LayoutInflater.from(context).inflate(R.layout.item_wucan, null);
			handle.tv_name=(TextView)view.findViewById(R.id.tv_name);
			handle.tv_num=(TextView)view.findViewById(R.id.tv_num);
			handle.tv_total=(TextView)view.findViewById(R.id.tv_total);
//			handle.tv_sname=(TextView)view.findViewById(R.id.tv_sname);
			view.setTag(handle);
		}else {
			handle = (ViewHandle) view.getTag();	
		}
		handle.tv_name.setText(wucanList.get(position).getName());
		handle.tv_num.setText(wucanList.get(position).getNum());
		handle.tv_total.setText(wucanList.get(position).getTotal());
//		if (caidanList.get(position).getSname().equals("")||caidanList.get(position).getSname().equals("null")) {
//			handle.tv_sname.setText("");
//		}else {
//			handle.tv_sname.setText("("+caidanList.get(position).getSname()+")");
//		}
		
		return view;
	}
	class ViewHandle {
		/**姓名*/
		TextView tv_name;
		/**次数*/
		TextView tv_num;
		/**消费金额*/
		TextView tv_total;
	}
}
